package cn.wolfcode.luowowo.website.controller;

import cn.wolfcode.luowowo.article.service.IStrategyCommendService;
import cn.wolfcode.luowowo.article.service.ITravelCommendService;
import cn.wolfcode.luowowo.article.service.ITravelService;
import cn.wolfcode.luowowo.cache.service.IStrategyStatsCacheService;
import cn.wolfcode.luowowo.common.query.TravelQuery;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

@Controller
public class IndexController {
    @Reference
    private ITravelCommendService travelCommendService;
    @Reference
    private IStrategyCommendService strategyCommendService;
    @Reference
    private ITravelService travelService;
    @Reference
    private IStrategyStatsCacheService strategyStatsCacheService;

    @RequestMapping("/")
    public String index(Model model){
        //tcs : 推荐游记5篇
        model.addAttribute("tcs", travelCommendService.listTop5());
        //scs : 推荐攻略5篇
        model.addAttribute("scs",strategyCommendService.listTop5());
        return "index/index";
    }


    @RequestMapping("/index/travelPage")
    public String travelPage(TravelQuery qo, Model model) {
        model.addAttribute("pageInfo",travelService.query(qo));
        return "index/travelPageTpl";
    }
}
